package com.zp.generic;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

//T类型必须是List<String>类型的子类；T<String>,尖括号里面必须也是String类型；
//在声明类型的时候就定义好了类型必须是List的子类；
public class GenericTest2<T extends List<String>>{ 
	private T array ;
	
	public T getArray() {
		return array;
	}

	public void setArray(T array) {
		this.array = array;
	}

	public static void main(String[] args) {
		GenericTest2<ArrayList<String>> g1 = new GenericTest2<ArrayList<String>>();
		GenericTest2<LinkedList<String>> g2 = new GenericTest2<LinkedList<String>>();
		
		ArrayList<String> arraylist = new ArrayList<String>();
		arraylist.add("a");
		arraylist.add("b");
		arraylist.add("c");
		
		g1.setArray(arraylist);
		System.out.println(g1.getArray());
		
		LinkedList<String> linkedlist = new LinkedList<String>();
		linkedlist.add("A");
		linkedlist.add("B");
		linkedlist.add("C");
		
		g2.setArray(linkedlist);
		System.out.println(g2.getArray());
	}
}
